package com.koko.service.impl;

import com.github.pagehelper.Page;
import com.koko.game.entity.GameRequire;
import com.koko.mapper.GameRequireMapper;
import com.koko.service.GameRequireService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GameRequireServiceImpl implements GameRequireService {
    @Autowired
    private GameRequireMapper gameRequireMapper;
    @Override
    public void save(GameRequire gameRequire) {
        gameRequireMapper.insert(gameRequire);
    }

    @Override
    public void deleteByGameId(Long gameId) {
        gameRequireMapper.deleteByGameId(gameId);
    }

    @Override
    public void update(GameRequire gameRequire) {
        gameRequireMapper.update(gameRequire);
    }

    @Override
    public List<GameRequire> getByGameId(Long gameId) {
        Page<GameRequire> gameRequirePage = gameRequireMapper.getTwoRequireByGameId(gameId);
        return gameRequirePage.getResult();
    }

    @Override
    public void add(GameRequire[] gameRequires) {
        for (GameRequire gameRequire : gameRequires) {
            gameRequireMapper.insert(gameRequire);
        }
    }
}
